"use strict";

var store = new Vuex.Store({
    state: {
        user: {
            "address": "",
            "balance": 0
        },
        web: {
            dividents: {
                "CLAIMABLE DIVS YASHA": {
                    id: 4,
                    value: 0,
                    method: ""
                }
            },
            chain: {
                "YASHA PRICE LEVEL": {
                    id: 0,
                    value: 0,
                    method: "CurLevel"
                },
                "YASHA PRICE HERE": {
                    id: 1,
                    value: 0,
                    method: "LevelPriceOf",
                    param: 1
                },
                "LOCKED YASHA": {
                    id: 2,
                    value: 0,
                    method: ""
                },
                "YASHA IN WALLET": {
                    id: 3,
                    value: 0
                },
                "CLAIMED DIVS YASHA": {
                    id: 6,
                    value: 0,
                    method: ""
                },
                "CLAIMED DIVS ETH": {
                    id: 7,
                    value: 0,
                    method: ""
                },
                "MINTED YASHA": {
                    id: 26,
                    value: 0,
                    method: "XTokenAmount"
                },
                "NEXT PRICE": {
                    id: 29,
                    value: 0,
                    method: ""
                },
                "COUNT YASHA": {
                    id: 30,
                    value: 0,
                    method: ""
                }
            },
            info: {
                "YASHA PRICE ON UNI.": {
                    id: 8,
                    value: 0,
                    method: ""
                },
                "ETH PRICE ON UNI.": {
                    id: 9,
                    value: 0,
                    method: ""
                }
            },
            pool: {
                'TOTAL USERS YASHA': {
                    id: 8,
                    value: 0,
                    method: ""
                },
                'DIVIDEND USERS YASHA': {
                    id: 9,
                    value: 0,
                    method: ""
                },
                'TOTAL USERS ETH': {
                    id: 10,
                    value: 0,
                    method: ""
                },
                'DIVIDEND USERS ETH': {
                    id: 11,
                    value: 0,
                    method: ""
                },
                'NUMBER OF USERS': {
                    id: 31,
                    value: 0,
                    method: ""
                },
                'COMPUTED USERS': {
                    id: 32,
                    value: 0,
                    method: ""
                }
            }
        }
    },
    mutations: {
        user_set: function user_set(state, obj) {
            for (var k in obj) {
                state.user[k] = obj[k];
            }
        },
        sign_out: function sign_out(state) {
            state.user.token = null;
            state.user.username = null;
            var path = location.pathname;
            var url = "/";

            if (path.indexOf('/admin') === 0 || path.indexOf('/agent') === 0) {
                this.$router.push('/');
            }
        },
        set_chain: function set_chain(state, obj) {
            for (var k in obj) {
                state.web.chain[k] = obj[k];
            }
        },
        set_pool: function set_pool(state, obj) {
            for (var k in obj) {
                state.web.pool[k] = obj[k];
            }
        },
        set_dividents: function set_dividents(state, obj) {
            for (var k in obj) {
                state.web.dividents[k] = obj[k];
            }
        },
        set_info: function set_info(state, obj) {
            for (var k in obj) {
                state.web.info[k] = obj[k];
            }
        }
    }
});